/**
 * 地址相关
 * 
 * @author 杨斌
 * @since 2019-05-19
 */
import common from './common'
import store from './store'

var ApiList = {};

//API 接口

/**
 * 收货地址
 */
ApiList.getUserAddressList = function(uid, okCb, failCb){
    var p = {
        uid,
    }
    common.Api('/user_address/searchList', p, okCb, failCb)
}


/**
 * 添加 / 修改 用户地址
 */
ApiList.setUserAddress = function(id, uid, contact_name, contact_mobile, sex, province_id, city_id, dist_id, street,okCb, failCb){
    var p = {
        uid,
        contact_name,
        contact_mobile,
        sex,
        province_id,
        city_id,
        dist_id,
        street,
    }
    if(id) p['id'] = id;
    common.Api('/user_address/item_submit', p, okCb, failCb)
}

/**
 * 删除用户地址
 */

ApiList.delUserAddress = function(id, uid, okCb, failCb){
    var p = {
        id,
        uid,
    }
    common.Api('/user_address/del', p, okCb, failCb)
}

/**
 * 设置用户默认地址
 */

ApiList.setUserDefaultAddress = function(id, uid, okCb, failCb){
    var p = {
        id,
        uid,
    }
    common.Api('/user_address/setDefault', p, okCb, failCb)
}

/**
 * 获取省市区
 */

ApiList.getAllAddress = function(id, type,okCb, failCb){
    var p = {
        id,
        type,
    }
    common.Api('/user_address/province', p, okCb, failCb)
}

/**
 * 获取可服务区域
 */

ApiList.getCanServeArea = function(okCb, failCb){
    var p = {
    }
    common.Api('/index/region', p, okCb, failCb)
}

/**
 * 获取地址详细信息
 */

ApiList.getAddressDetail = function(uid, id, okCb, failCb){
    var p = {
        uid,
        id,
    }
    common.Api('/user_address/item', p, okCb, failCb)
}

export default ApiList;

